package com.qianyu.project.mapper.provider;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qianyu.project.core.bean.FundEssentialinformation;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.ObjectUtils;

import java.util.Map;

/**
 * @author:xz
 * @Date: Created in 2021/2/12 18:37
 */
public class ExpendFundPlanProvider {


    public String selectPageList(IPage page, Map<String, String> params) {
        String sql =  new SQL() {
            {
                SELECT("*");
                FROM("fund_essentialinformation");
                if (!ObjectUtils.isEmpty(params.get("fundplanName"))) {
                    WHERE("fundplan_name like '%${params.fundplanName}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("planId"))) {
                    WHERE("plan_id like '%${params.planId}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("projectName"))) {
                    WHERE("project_name like '%${params.projectName}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("filledBy"))) {
                    WHERE("filled_by like '%${params.filledBy}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("approveStatus"))) {
                    WHERE("approveStatus = #{params.approveStatus} ");
                }
            }
        }.toString();
        System.out.println(sql);
        return sql;
    }
}
